package com.lily.ssm.service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.lily.ssm.mapper.ProductMapper;
import com.lily.ssm.model.Product;
import com.lily.ssm.model.ProductClass;

@Service
public class ProductService {
	
	@Autowired
	private ProductMapper productMapper;
	
	//修改数据
	public int insertProdut(Product record){
		return productMapper.insert(record);
	}
	
	//分页查询Product
	public List<Product> getProduct(int offset){
		return productMapper.getProduct(offset);
	}
	
	//根据productId查询Product
	public Product selectProduct(int productId){
		return productMapper.selectByPrimaryKey(productId);
	}
	
	//查询ProductClass中的所有二级分类
	public List<ProductClass> getTwoList(){
		return productMapper.getTwoList();
	}
	
	//修改
	public int updateProduct(Product record){
		return productMapper.updateByPrimaryKeySelective(record);
	}
	
	//删除
	public int deleteProduct(int productId){
		return productMapper.deleteByPrimaryKey(productId);
	}
	
	//获取Product中共有多少数据
	public int getCount(){
		return productMapper.getCount();
	}
	
	//根据classId,productName条件获取Product集合
	public List<Product> getProductListById(Map<String, Object> hashmap){
		return productMapper.selectProduct(hashmap);
	}
	
	//获取查询的总记录数
	public int getSelectCount(Map<String, Object> hashmap){
		return productMapper.getSelectCount(hashmap);
	}
}
